package com.yiwei.hdb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.Spanned;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yiwei.hdb.R;
import com.yiwei.hdb.adapter.base.ItemAdapter;
import com.yiwei.hdb.model.MoneyLogModel;
import com.yiwei.hdb.util.Spans;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/10/17 0017.
 */

public class MyFundDetailAdapter extends ItemAdapter<MoneyLogModel.Data, MyFundDetailAdapter.CreditScoreViewHolder> {
    private final int px30;
    private final int px26;
    private Context context;

    public MyFundDetailAdapter(Context context) {
        super(context);
        this.context = context;
        px30 = context.getResources().getDimensionPixelSize(R.dimen.x30);
        px26 = context.getResources().getDimensionPixelSize(R.dimen.x26);
    }

    @Override
    public CreditScoreViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new CreditScoreViewHolder(inflate(R.layout.item_credit_score, parent));
    }

    @Override
    public void onBindViewHolder(CreditScoreViewHolder holder, int position) {
        MoneyLogModel.Data item = getItem(position);
        holder.txtContent.setText(item.type_name);
        holder.txtScore.setText(item.money);


        holder.txtTime.setText(item.create_time_format);


        Spanned rightContent = Spans.with(context).font(item.money, px30, 0xff111111).p().font(item.account_money + "", px26, 0xffcacaca).build();
        holder.txtScore.setText(rightContent);
    }

    static class CreditScoreViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_content)
        TextView txtContent;
        @BindView(R.id.txt_time)
        TextView txtTime;
        @BindView(R.id.txt_score)
        TextView txtScore;

        public CreditScoreViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
